<?php
class usersRoles extends Model
	{
		var $database_config = 'db_config_default';
		public $name = 'users_roles';
		public $table_name = 't_users_roles';
		public $stored_procedure_list = 'sp_users_roles_list';
		public $stored_procedure_list_paged = 'sp_users_roles_list_paged';
		public $stored_procedure_update = 'sp_users_roles_update';
		public $stored_procedure_get = 'sp_users_roles_get';
		public $stored_procedure_delete = 'sp_users_roles_delete';
		public $stored_procedure_insert = 'sp_users_roles_insert';
		public $db_structure = array
		(
		
			'id' => array			
			(
				'name' => 'user_role_id', 
				'type'=>'bigint',
				'primary_key'=>true,
				'not_null'=>true
			),
					
			'role_id' => array			
			(
				'name' => 'role_id', 
				'type'=>'bigint',
				'primary_key'=>false,
				'not_null'=>true
			),

			'user_id' => array			
			(
				'name' => 'user_id', 
				'type'=>'bigint',
				'primary_key'=>false,
				'not_null'=>true
			),			
			
			'name' => array			
			(
				'name' => 'role_name', 
				'type'=>'varchar',
				'length'=>'100',
				'not_null'=>true
			),
			
			'description' => array			
			(
				'name' => 'role_description', 
				'type'=>'text',
				'not_null'=>false
			),	

			'in_role' => array			
			(
				'name' => 'in_role', 
				'type'=>'bit',
				'not_null'=>false
			),	
		
			
		);
		
		function GetByUserId($user_id)
		{
			return $this->Execute(array('user_id'=>$user_id),'sp_users_roles_list_by_user_id');
		}
		
		function AddUserRole($userId, $roleId, $refresh)
		{
			return $this->Execute(array('user_id'=>$userId, 'role_id'=>$roleId),'sp_users_roles_update');
		}	
	}
?>